package com.xbts.common.core.web.domain;

import com.xbts.common.core.enums.DateTypeEnum;
import com.xbts.common.core.utils.DateUtils;
import lombok.Data;

import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.List;

/**
 * 树状图基础类
 *
 * @author xbts
 */
@Data
public class BaseHistogramResult {

    /**
     * X轴
     */
    List<String> xAxis;

    /**
     * 目标值
     */
    List<String> target;

    /**
     * 实际值
     */
    List<String> actual;

    public BaseHistogramResult() {

    }

    public BaseHistogramResult(DateTypeEnum dateType) {
        List<String> list = new ArrayList<>();
        List<String> list2 = new ArrayList<>();
        switch (dateType) {
            case DAY:
                for (int i = 0; i < YearMonth.from(LocalDate.now()).lengthOfMonth(); i++) {
                    list.add("0");
                    list2.add("0");
                }
                this.xAxis = DateUtils.getDaysOfMonth();
                break;
            case WEEK:
                for (int i = 0; i < 8; i++) {
                    list.add("0");
                    list2.add("0");
                }
                this.xAxis = DateUtils.getLastEightWeeks();
                break;
            case MONTH:
                for (int i = 0; i < 12; i++) {
                    list.add("0");
                    list2.add("0");
                }
                this.xAxis = DateUtils.getLastTwelveMonths();
                break;
        }
        this.target = list;
        this.actual = list2;
    }


}
